

    var change = function(){
    	$oppType = $("#opp_type");
    	$oppFactor= $("#opp_factor");
    	
    	if($oppFactor.val()=="情报"){
    		hide($("#ys_xq_400"));  
    		hide($("#ys_xq_sms"));    
    		hide($("#ys_xq_data"));    
    		hide($("#ys_xq_audio"));    
    		hide($("#ys_yd")); 
    		show($("#ys_qb"));
    	}else if($oppFactor.val()=="异动"){
    		hide($("#ys_xq_400"));  
    		hide($("#ys_xq_sms"));    
    		hide($("#ys_xq_data"));    
    		hide($("#ys_xq_audio"));    
    		hide($("#ys_qb")); 
    		show($("#ys_yd"));
    	}else if($oppFactor.val()=="需求"){
    		hide($("#ys_qb"));
    		hide($("#ys_yd"));
    		if($oppType.val()=="移动400"){
    			show($("#ys_xq_400"));  
        		hide($("#ys_xq_sms"));    
        		hide($("#ys_xq_data"));    
        		hide($("#ys_xq_audio")); 
    			
    		} else if($oppType.val()=="集团短信"){
    			hide($("#ys_xq_400"));  
        		show($("#ys_xq_sms"));    
        		hide($("#ys_xq_data"));    
        		hide($("#ys_xq_audio")); 
    			
    		}else if($oppType.val()=="语音专线"){
    			hide($("#ys_xq_400"));  
        		hide($("#ys_xq_sms"));    
        		hide($("#ys_xq_data"));    
        		show($("#ys_xq_audio")); 
    			
    		}else if($oppType.val()=="数据专线"){
    			hide($("#ys_xq_400"));  
        		hide($("#ys_xq_sms"));    
        		show($("#ys_xq_data"));    
        		hide($("#ys_xq_audio")); 
    			
    		}
    		
    	}
    	
    };
    
    
    
    var addSucc =function(data){
    	alert("添加成功");
    	$("#submit").html("提交");
       	if($("#submit").hasClass("am-disabled")){
    		$("#submit").removeClass("am-disabled");
    	}
    	window.history.go(-1);
    	
    };
    
    var buildParams = function(){
    	var params=null;
    	var oppType = $("#opp_type").val();
    	var oppFactor = $("#opp_factor").val();
    	var groupName = decodeURI(getParamValue("grpName"));
    	var status="待分派";
    	var progress = "";
    	
    	if(oppFactor=="情报"){
    		params = {"bus_type":oppType,"group_name":groupName,"group_no":getParamValue("grpId"),"k1":oppType,"k2":oppFactor,"k3":status,"k4":progress,"k5":$("#qb_endDate").val(),"k6":$("#qb_competitor").val(),"k7":$("#qb_theme").val(),"k8":$("#qb_desc").val(),"k9":$("#qb_remark").val()};
    	}else if(oppFactor=="异动"){
    		params = {"bus_type":oppType,"group_name":groupName,"group_no":getParamValue("grpId"),"k1":oppType,"k2":oppFactor,"k3":status,"k4":progress,"k5":$("#yd_endDate").val(),"k6":$("#yd_competitor").val(),"k7":$("#yd_theme").val(),"k8":$("#yd_bus_type").val(),"k9":$("#yd_sub_type").val(),"k10":$("#yd_desc").val(),"k11":$("#yd_remark").val()};
    	}else if(oppFactor=="需求"){
    		
    		if(oppType=="移动400"){
    			var needSms = $("#needSms").is(':checked')?"是":"否";
    			params = {"bus_type":oppType,"group_name":groupName,"group_no":getParamValue("grpId"),"k1":oppType,"k2":oppFactor,"k3":status,"k4":progress,"k5":$("#400").val(),"k6":needSms,"k7":$("#400_sms_sign").val(),"k8":$("#400_startDate").val(),"k9":$("#400_fee_require").val(),"k10":$("#400_name").val(),"k11":$("#400_phone").val(),"k12":$("#400_addr").val()};
    			
    		} else if(oppType=="集团短信"){
    			params = {"bus_type":oppType,"group_name":groupName,"group_no":getParamValue("grpId"),"k1":oppType,"k2":oppFactor,"k3":status,"k4":progress,"k5":$("#platType").val(),"k6":$("#sms_sms_sign").val(),"k7":$("#sms_startDate").val(),"k8":$("#sms_fee_require").val(),"k9":$("#serviceCode").val(),"k10":$("#sms_name").val(),"k11":$("#sms_phone").val(),"k12":$("#sms_addr").val()};
    			
    		}else if(oppType=="语音专线"){
    			params = {"bus_type":oppType,"group_name":groupName,"group_no":getParamValue("grpId"),"k1":oppType,"k2":oppFactor,"k3":status,"k4":progress,"k5":$("#access_addr").val(),"k6":$("#phones").val(),"k7":$("#audio_startDate").val(),"k8":$("#audio_fee_require").val(),"k9":$("#audio_name").val(),"k10":$("#audio_phone").val(),"k11":$("#audio_addr").val()};
    		}else if(oppType=="数据专线"){
    			params = {"bus_type":oppType,"group_name":groupName,"group_no":getParamValue("grpId"),"k1":oppType,"k2":oppFactor,"k3":status,"k4":progress,"k5":$("#a_addr").val(),"k6":$("#z_addr").val(),"k7":$("#rate").val(),"k8":$("#data_start_date").val(),"k9":$("#data_fee_require").val(),"k10":$("#data_name").val(),"k11":$("#data_phone").val(),"k12":$("#data_addr").val()};
    		}
    		
    	}
    	return params;
    };
    
    $(function(){
        $("#opp_type").on('change', function() {
        	change();  
        });
        
        $("#opp_factor").on('change', function() {
          	change();
        });
        
        $("#submit").on('click', function(){
        	$("#submit").html("<i class='am-icon-spinner am-icon-spin'></i>&nbsp&nbsp&nbsp&nbsp提交中……");
        	if(!$("#submit").hasClass("am-disabled")){
        		$("#submit").addClass("am-disabled");
        	}
        	var params=buildParams();
        	sendDzgPostAjax(params,"../../../opponent/addIdc",addSucc);
        });
        
        
    	
    });